<div style="position: absolute;top: 120px; left: 450px">
    <font style="font-size: 25px ;color: #e8198b">库存查询：</font>&nbsp;&nbsp;
    产品编号：<input type="text" class="su" id="productCode" >&nbsp;
    产品名称：<input type="text" class="su" id="name">
    库存范围:<input type="text" id="min" value="0" style="width: 50px;border-radius: 50px;
    height: 25px;
    background: #84fab0;
    border-color: #0eb4dd;">--<input type="text" style="width: 50px;border-radius: 50px;
    height: 25px;
    background: #84fab0;
    border-color: #0eb4dd;" id="max">
    <input type="button" value="查询" onclick="selectProduct()" style="background-color: #1E9FFF">
</div>
<br>
<table class="altrowstable">
    <tr>
        <td>编号</td>
        <td>产品编号</td>
        <td>产品名称</td>
        <td>库存数量</td>
        <td>采购在途数</td>
        <td>预销售数</td>
        <td>变更记录</td>
    </tr>
    <tbody id="stockBody">

    </tbody>
    <div  style="position: absolute; margin-top: 0px;padding-left: 700px">
        <ul id="page">分页</ul>
    </div>
</table>


<script type="text/html" id="stockTemplate">
    {{each data}}
    <tr>
        <td>{{$index+1}}</td>
        <td>{{$value.productCode}}</td>
        <td>{{$value.name}}</td>
        <td>{{$value.num}}</td>
        <td>{{$value.poNum}}</td>
        <td>{{$value.soNum}}</td>
        <td><font style="color: #e8198b" onclick="{{'getStock(\''+ $value.productCode +'\')'}}">查看明细</font></td>
    </tr>
    {{/each}}
</script>
<script>

    function selectProduct() {
        Ajax.post('selectProduct',{
            productCode:$('#productCode').val(),
            name:$('#name').val(),
            min:$('#min').val(),
            max:$('#max').val()
        },function (result) {
            var str = template("stockTemplate",result);
            document.getElementById("stockBody").innerHTML=str;
        })
    }


    function getStock(productCode){
    Ajax.getHtml('StockRecords.html',function (html) {
        Ajax.post('getStock',{
            productCode:productCode
        },function (result) {
            var str = template("stockRecord",result);
            document.getElementById("stockItem").innerHTML=str
        });
        layer.open({
            type:1,
            title:'库存变更记录查看',
            area: ['800px',['400px']],
            content: html,
            btn: ['确认', '取消'],
            yes:function () {
                layer.closeAll();
            }
        })

    })
    }



    $(function () {
        showPage({
            currentPage: 1,
            pageSize: 3,
            url:'/productList',
            templateId:"stockTemplate",
            contentId:"stockBody"
        })
    })
</script>
